#!/usr/bin/env bash
#--------------------------------------------
# author：qierkang
# site：https://www.qekang.com
#--------------------------------------------
##### start #####
#
# lancaster-manage 自动部署脚本文件
#
##### end  #####
sleep 1
echo 'Docker自动化-环境镜像打包启动中...'
sleep 1
echo 'Docker自动化-环境镜像打包启动中.......'
sleep 1
echo '==================author================================'
echo 'author：qierkang'
echo 'site：https://www.qekang.com'
echo '==================author================================'
sleep 2
echo '=============自动部署脚本文件==========='
echo '==================1.开发环境准备========================='
echo '1.1请确保安装并java8, git, maven并设置好环境变量'
echo '1.2请确保安装并docker,docker-compose并设置好环境变量'
url=/Users/qierkang/InsertList/IdeaProjects/money/lancaster-parent
echo '=============开始停止服务==========='
docker rm -f $(docker ps -a | grep lancaster-manage | awk '{print $1}')
sleep 1
echo '=============开始删除镜像==========='
docker rmi $(docker images | grep lancaster-manage | awk '{print $3}')
sleep 1
#返回根目录
source ~/.bash_profile
echo '当前目录:' && pwd
sleep 1
echo '==================安装认证公共包到本地maven仓库=================='
#安装认证公共包到本地maven仓库
cd $url/lancaster-model && mvn clean install
cd $url/lancaster-utils && mvn clean install
##回到根目录
sleep 1
echo '==================构建镜像并启动(||)相关服务=================='
#构建镜像:lancaster-manage
#cd $url/lancaster-manage && mvn clean install
cd $url/lancaster-manage && mvn clean package && mvn docker:build
#启动服务
docker run -d -p 8899:8899 lancaster/lancaster-manage:latest
#打印日志
docker logs -f $(docker ps -a | grep lancaster-manage | awk '{print $1}')
#docker-compose -f lancaster-manage.yml up -d
#docker-compose -f lancaster-manage.yml up --scale lancaster-manage=3 -d
